
<template>
	<view class="page_box">
		<view class="head_box">
			<!-- <ljshop-navbar :background="{ background: 'none' }" backText="推广中心" backIconColor="#333"></ljshop-navbar> -->
			<view class="all-box">
				<view class="all-title u-m-b-30">推广总数</view>
				<view class="all-num">{{ count || 0 }}</view>
				<image class="score-card-bg" :src="$IMG_URL + '/imgs/score/score_wallet_bg.png'" mode=""></image>
			</view>
	 
		</view>
		<view class="content_box">
				<scroll-view scroll-y="true" @scrolltolower="loadMore" class="scroll-box">
					<view v-for="item in teamList" :key="item.id" class="con-box">
						<view class="name-box">
							<view class="name">
								{{item.hzMemberVO.username}}
							</view>
							<view class="mobile">
								<span class="top">手机号：</span>
								<span class="bottom">{{item.hzMemberVO.mobile}}</span>
							</view>
							<view class="time">
								<span class="top">创建时间：</span>
								<span class="bottom">{{$u.timeFormat(item.hzMemberVO.createdDate)}}</span>
							</view>
						</view>
						<view class="num-box">
							<img src="https://image.hzwltb69.com/app/imgs/chat/allpep.png" alt="">
							<view class="">
								人数：
							</view>
							<view class="">
							 {{item.childrenCount}}
							</view>
						</view>
						<view @click="goInfo(item.memberId)" class="arrow">
							<img v-if="item.childrenCount !== 0" src="https://image.hzwltb69.com/app/imgs/score/arrows.png" alt="">
						</view>
					</view>
				<!-- 空置页 -->
				<!-- 更多 -->
				<u-loadmore v-if="teamList.length" height="80rpx" :status="loadStatus" icon-type="flower" color="#ccc" />
			</scroll-view>
		</view>
		
	</view>
</template>

<script>
 
	import {
		mapMutations,
		mapActions,
		mapState,
		mapGetters
	} from 'vuex';
	export default {
		components: {
		 
		},
		data() {
			return {
				isEmpty: false,
				TeamCount:0,
				referrerInfo: {}, //推荐人信息
				twoTeamCount: 0, //二级成员
				teamList: [], //团队列表
				loadStatus: 'loadmore', //loadmore-加载前的状态，loading-加载中的状态，nomore-没有更多的状态
				currentPage: 1,
				lastPage: 0,
				count:0,
				isRefresh: false,
				hasMroe:true
			};
		},
		computed: {
			...mapGetters(['userInfo', 'agentInfo'])
		},
		onLoad() {
			this.getTeam();
			this.getTotal()
		},
		onReachBottom() {
					this.currentPage += 1;
					this.getTeam();
		},
		
		methods: {
			getTotal(){
				this.$http('user.getTotal')
				.then(res=>{
					this.count = res.data.all
				})
			},
			goInfo(e){
				this.$Router.push({
					path: '/pages/app/commission/teamDown',
					query:{
						id:e
					}
				})
			},
			getTeam() {
				let that = this;
				 
				that.loadStatus = 'loadmore';
				that.$http('commission.team', {
					current: that.currentPage,
					pageSize: 20,
					UId: 0
				}).then(res => {
					if (res.code == 1) {
						that.referrerInfo = res.data;
						let arr = res.data.lsit;
						 
						if(that.currentPage == 1){
							that.teamList = arr;
						} else if(res.data.lsit.length > 0) {
							that.teamList=that.teamList.concat(arr)
						}else{
							this.currentPage -= 1
						}
						if( res.data.lsit.length<20){
							that.loadStatus = 'nomore';
							that.hasMroe =false;
						}
					}
				});
			},

			// 加载更多
			loadMore() {
				if(this.hasMroe){
					
					this.currentPage += 1;
					this.getTeam();
				}
			}
		}
	};
</script>

<style lang="scss">
	.page_box{
		background: #f7f6f6 !important;
	}
	// 推荐人
	.referrer-box {
		font-size: 28rpx;
		font-weight: 500;
		color: #ffffff;
		margin-top: 10rpx;
	
	.referrer-avatar {
			width: 34rpx;
			height: 34rpx;
			border-radius: 50%;
		}
	}

	// 二级加载更多按钮
	.refresh-btn {
		width: 100%;
		line-height: 100rpx;
		background: #ffffff;
		border-radius: 25rpx;
		font-size: 22rpx;
		font-weight: 500;
		color: #999999;
		white-space: nowrap;
	}

	.refresh-active {
		transform: rotate(360deg);
		transition: all linear 0.5s;
	}

	// 头部卡片
	.head_box {
		background: url($IMG_URL+'/imgs/commission/card_bg.png') no-repeat;
		background-size: 100% 100%;
		// padding-bottom: 30rpx;
	}

	// 团队信息总览
	.team-data-box {
		margin: 30rpx 20rpx 0;

		.data-card {
			width: 750rpx;
			background: #ffffff;
			border-radius: 20rpx;
			padding: 20rpx;

			.item-title {
				font-size: 22rpx;
				font-weight: 500;
				color: #999999;
				line-height: 30rpx;
				margin-bottom: 10rpx;
				text-align: center;
			}

			.total-item {
				margin-bottom: 20rpx;
			}

			.total-num {
				font-size: 38rpx;
				font-weight: 500;
				color: #333333;
				text-align: center;
			}

			.category-num {
				font-size: 26rpx;
				font-weight: 500;
				color: #333333;
				text-align: center;
			}
		}
	}

	// 团队列表
	.team-box {
		.team-list {
			.team-children {
				margin-left: 80rpx;
				margin-right: 20rpx;
				height: 132rpx;
				border-bottom: 1rpx solid #eee;

				.head-img {
					width: 60rpx;
					height: 60rpx;
					border-radius: 50%;
					margin-right: 38rpx;
				}

				.head-info {
					.head-time {
						font-size: 22rpx;
						font-weight: 400;
						color: #999999;
					}

					.name-box {
						margin-bottom: 12rpx;

						.name-text {
							font-size: 24rpx;
							font-weight: 500;
							color: #666;
						}

						.tag-box {
							background: rgba(0, 0, 0, 0.2);
							border-radius: 21rpx;
							line-height: 30rpx;
							padding-right: 10rpx;
							margin-left: 10rpx;

							.tag-img {
								width: 34rpx;
								height: 34rpx;
								margin-right: 6rpx;
								border-radius: 50%;
							}

							.tag-title {
								font-size: 18rpx;

								font-weight: 500;
								color: rgba(255, 255, 255, 1);
								line-height: 20rpx;
							}
						}
					}
				}
			}
		}
	}

	.page_box {
		background: #fff;

		.head_box {
			width: 750rpx;
			background: linear-gradient(180deg, rgba(239, 196, 128, 1) 0%, rgba(248, 220, 165, 1) 40%, rgba(255, 255, 255, 1) 100%) no-repeat;
			position: relative;
			.all-box {
				color: #2d485f;
				display: flex;
				align-items: center;
				justify-content: center;
				padding-top: 50rpx;
				flex-direction: column;
				// height: 360rpx;
				padding-bottom: var(--status-bar-height);

				.all-num {
					font-size: 50rpx;
					font-weight: 600;
					// color: #a8700d;
					margin-bottom: 20rpx;
				}

				.all-title {
					font-size: 24rpx;
					font-weight: 500;
					// color: rgba(168, 112, 13, 1);
				}

				.score-card-bg {
					width: 100%;
					height: 90rpx;
				}
			}

			.tab-box {
				position: absolute;
				left: 50%;
				bottom: 0;
				transform: translateX(-50%);
				width: 710rpx;
				height: 90rpx;
				background: rgba(255, 255, 255, 1);
				border-radius: 30rpx 30rpx 0px 0px;
				border-bottom: 1rpx solid #dfdfdf;
				padding: 0 30rpx;

				.tab-item {
					flex: 1;

					.tab-name {
						display: inline-block;
						font-size: 30rpx;
						font-family: Noto Sans S Chinese;
						font-weight: 400;
						color: rgba(51, 51, 51, 1);
						border-bottom: 4rpx solid transparent;
						line-height: 86rpx;
					}

					.tab-active {
						border-bottom: 4rpx solid rgba(213, 166, 90, 1);
					}
				}
			}
		}
	}

	.item-box {
		background: #fff;
		border-bottom: 1rpx solid #dfdfdf;
		padding: 30rpx;

		.name {
			font-size: 28rpx;
            text-align: center;
			height: 60rpx;
			line-height: 60rpx;
			font-weight: 500;
			color: rgba(102, 102, 102, 1);
		
		}

		.time {
			font-size: 24rpx;

			font-weight: 500;
			color: rgba(196, 196, 196, 1);
			line-height: 24px;
		}

		.num {
			font-size: 30rpx;

			font-weight: 500;
			color: #e6b873;
		}
	}
	.content_box{
		position: absolute;
		top: 250rpx;
		padding-left: 30rpx;
		padding-right: 30rpx;
		.scroll-box{
			width: 690rpx;
		}
		.con-box{
			width: 100%;
			height: 160rpx;
			background-color: #ffffff;
			border-radius: 25rpx;
			margin-bottom: 25rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding-left: 20rpx;
			padding-right: 20rpx;
			.name-box{
				display: flex;
				flex-direction: column;
				.top{
					color: #9ea5af;
					font-size: 25rpx;
				}
				.bottom{
					color:#697784 ;
					font-size: 25rpx;
				}
				.name{
					font-weight: 600;
					font-size: 33rpx;
					color: #2d485f;
				}
				.mobile{
					
				}
				.time{
					
				}
			}
			.num-box{
				// width: 150rpx;
				padding-left: 20rpx;
				padding-right: 20rpx;
				height: 70rpx;
				border-radius: 30rpx;
                 background: #EDFAF8;
				display: flex;
				align-items: center;
				justify-content: center;
				color: #53cdba;
				img{
					width: 50rpx;
					height: 50rpx;
				}
			}
			.arrow{
				img{
					width: 35rpx;
					height: 35rpx;
				}
			}
		}
	}
</style>
